home *** CD-ROM | disk | FTP | other *** search
- #!/usr/bin/perl5
- #
- # nsd-edit.frm
- #
- # Copyright 1988-1996 Silicon Graphics, Inc.
- # All rights reserved.
- #
- # This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- # the contents of this file may not be disclosed to third parties, copied or
- # duplicated in any form, in whole or in part, without the prior written
- # permission of Silicon Graphics, Inc.
- #
- # RESTRICTED RIGHTS LEGEND:
- # Use, duplication or disclosure by the Government is subject to restrictions
- # as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- # and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- # successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- # rights reserved under the Copyright Laws of the United States.
- #
-
- BEGIN { require "/usr/WebFace/lib/CGI.pm"; import CGI; }
- require "/usr/OnRamp/lib/OnRamp.pm";
- require "/usr/OnRamp/lib/java.pm";
-
- $query = new CGI;
-
- $title = "Unified Name Service";
- $myname = "nsd-edit.cgi";
- $help_page = "nsd-config-help.html";
- $conf_page = "/admin/nsd-config.cgi";
-
-
- $js =
- "$js_standard
- $js_help
- $js_error_box
- function checkForm(form) {
- return (true);
- }";
-
-
- if ($query->param) {
- @names = $query->param;
- $num_new = $query->param('num_new');
- $total_libs = $query->param('total_libs');
- if ($#names == $total_libs+2) {
- if ($num_new <= 0) { # No changes
- &redirect($conf_page);
- exit;
- } else { # Just adding maps
- $instructions = "<blockquote>
- Please enter the name of each new map in the space
- provided and choose its order of lookup services.
- When you're done, use the \"Ok\" button.
- </blockquote><p>\n";
- }
- } else {
- if ($num_new > 0) { # Changing and adding
- $instructions = "<blockquote>Enter the name of each
- new map in the space provided and choose the order of
- lookup services for all maps. When you're done, use the
- \"Ok\" button to view your changes. </blockquote><p>\n";
- } else { # Just changing
- $instructions = "<blockquote>Please choose the order
- of lookup services for each map. When you're done,
- use the \"Ok\" button to view your changes.
- </blockquote><p>\n";
- }
- }
-
- print $query->header;
- &list_libraries;
- &generic;
-
- } else {
- redirect($conf_page);
- exit;
- }
-
- sub list_libraries {
- local (@files);
- opendir (NSLIBS, "/var/ns/lib");
- @files = grep(!/^\./, readdir(NSLIBS));
- closedir(NSLIBS);
- foreach $file (@files) {
- undef $symlink;
- $symlink = true if (-l "/var/ns/lib/$file");
- $file =~ s/^libns_//g;
- $file =~ s/\.\w*$//g;
- push (@choices,$file) if (! $symlink);
- }
- push (@choices,"none");
- }
-
- sub generic {
- &js_title_block($title,$js);
- &header_block($title);
-
- # Check if just deleting maps
- foreach $map (@names) {
- push (@edit, $map)
- if ($map !~ /^doit$/ && $map !~ /^num_new$/ &&
- $map !~ /^total_libs$/ && $map !~ /_lib\d+$/ &&
- $map !~ /^del_/);
- }
- if (! @edit && $num_new < 1) {
- $instructions = "These are the maps you chose to delete. Use "
- . "the \"Ok\" button to delete them from your UNS "
- . "configuration file.";
- }
-
- # Print form header
- print $query->startform("POST", "summary.cgi", "",
- "NAME=StandardForm", "onSubmit=\"return runSubmit()\"");
- print $instructions;
- print qq|<font size="+1"><center><table>\n|;
- print "<tr><th><th>First<th>Next<th>Last</tr>\n" if (@edit || $num_new > 0);
-
- # Changing existing maps
- foreach $map (@names) {
- next if ($map =~ /^doit$/);
- next if ($map =~ /^num_new$/);
- next if ($map =~ /^total_libs$/);
- next if ($map =~ /_lib\d+$/);
-
- if ($map =~ /^del_/) {
- $map =~ s/del_//g;
- $hidden .= "<input type=hidden name=$map value=delete>\n";
- push (@delete, $map);
- next;
- }
-
- for ($i = 0; $i < 3; $i++) {
- $libname = $map . "_lib" . $i;
- $order[$i] = $query->param($libname);
- $order[$i] = "none" if (! $order[$i]);
- }
- $order[0] = "files" if ($order[0] eq "none");
-
- print "<tr><td align=left><b>$map: </b>\n";
- for ($j = 1; $j < 4; $j++) {
- $name = $map . "_" . $j;
- print "<td align=center>", $query->popup_menu(-name=>"$name",
- -values=>\@choices,
- -default=>$order[$j-1]);
- $name = "old_" . $map . "_" . $j;
- print "<input type=hidden name=$name value=\"$order[$j-1]\">\n\n";
- }
- }
-
- # Adding new maps
- if ($num_new > 0) {
- @order = ("files", "none", "none");
- print qq|<input type=hidden name=num_new value="$num_new">\n|;
- for ($i = 0; $i < $num_new; $i++) {
- print "<tr><td align=left>";
- $name = "new" . $i . "_name";
- print qq|<b><input name="$name" size=10>:</b>\n|;
- for ($j = 1; $j < 4; $j++) {
- $name = "new" . $i . "_" . $j;
- print "<td align=center>", $query->popup_menu(-name=>"$name",
- -values=>\@choices,
- -default=>$order[$j-1]);
- }
- }
- }
-
- # Deleting existing maps
- if (@delete) {
- print "<tr><td colspan=4><br>";
- print "<b><i>Maps to be deleted:</i></b>\n";
- foreach $map (@delete) {
- print "<tr><td><b>$map</b>\n";
- }
- }
- print $hidden;
- print "</tr>";
- print "</table></center>";
- print "<p>\n";
-
- print &js_buttons('doit','Ok','onClick="markOK()"','onClick="markOther()"',
- "onClick=\"do_help('$help_page'); return (false)\"");
-
- print $query->endform;
- }
-